axios.defaults.baseURL = 'http://www.liulongbin.top:3007'
axios.interceptors.request.use(function (config) {
  if (config.url.indexOf('/my') !== 1) {
    config.headers.Authorization=localStorage.getItem('token')
  }
return config
 }, function (error) {
  return Promise.reject(error)
})
axios.interceptors.response.use(function (response) {
  if (response.data.message==='身份认证失败！') {
    location.href = '/login.html'
    localStorage.removeItem('token')
  }
return response
 }, function (error) {
  return Promise.reject(error)
})
// 格式化日期
function formaData(time) {
  let dt = new Date(time)
  let y = dt.getFullYear()
  let m = padZer0(dt.getMonth() + 1)
  let d = padZer0(dt.getDate())

  let hh = padZer0(dt.getHours())
  let mm = padZer0(dt.getMinutes())
  let ss = padZer0(dt.getSeconds())

  return `${y}:${m}:${d}:${hh}:${mm}:${ss}`
}
function padZer0(n) {
  return n < 10 ? '0' + n : n
}